package com.zly.framework.rbac.model.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.zly.framework.rbac.model.entity.Permission;
import com.zly.framework.rbac.model.entity.Role;
import com.zly.framework.rbac.vaildate.EntityInsert;
import com.zly.framework.rbac.vaildate.EntityUpdate;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.util.List;

@Data
@Schema(name = "用户视图")
public class UserVo {

    @ExcelProperty("用户名")
    @Schema(description = "登录账号")
    @NotBlank(message = "用户名不能为空", groups = {EntityInsert.class})
    private String username;

    @ExcelProperty("昵称")
    @Schema(description = "昵称")
    @Length(min = 1, max = 20, message = "昵称的长度为1-20", groups = {EntityInsert.class, EntityUpdate.class})
    private String nickname;

    @ExcelProperty("密码")
    @Schema(description = "密码")
    @NotBlank(message = "密码不能为空", groups = {EntityInsert.class})
    private String password;

    @ExcelProperty("联系电话")
    @Schema(description = "联系电话")
    @Pattern(regexp = "^1[3-9][0-9]{9}$", message = "手机号格式有误", groups = {EntityInsert.class, EntityUpdate.class})
    private String phone;

    @ExcelProperty("邮箱")
    @Schema(description = "邮箱")
    @Pattern(regexp = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$", message = "邮箱格式错误", groups = {EntityInsert.class, EntityUpdate.class})
    private String email;

    @ExcelProperty("描述")
    @Schema(description = "描述")
    private String description;

    @ExcelProperty("头像")
    @Schema(description = "头像")
    private String photo;

    @ExcelProperty("性别")
    @Schema(description = "性别")
    private int sex;

    private List<Role> roles;

    private List<Permission> permissions;
}
